package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Major;
import com.example.entity.Resource;
import com.example.vo.ResourceVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

public interface ResourceMapper extends BaseMapper<Resource> {
    @Insert("insert into tb_resource (resource_title,resource_url,pic_url,major_id)VALUES(#{resourceTitle},#{resourceUrl},#{picUrl},#{majorId})")
    Integer addResource(
                        @Param("resourceTitle")  String resourceTitle,
                        @Param("resourceUrl")    String resourceUrl,
                        @Param("picUrl")         String picUrl,
                        @Param("majorId")        Integer majorId);

    @Update("update tb_resource set resource_title = #{resourceTitle},resource_url =#{resourceUrl},pic_url= #{picUrl} ,major_id =#{majorId} where id= #{id}")
    Integer updateResource(@Param("id")             Integer id,
                           @Param("resourceTitle")  String resourceTitle,
                           @Param("resourceUrl")    String resourceUrl,
                           @Param("picUrl")         String picUrl,
                           @Param("majorId")        Integer majorId);

    /**
     * 查看所有的资源
     * @return
     */
    List<ResourceVO> selectResource(@Param("majorId") Integer majorId,
                                    @Param("page") Integer page,
                                    @Param("limit") Integer limit);


}
